

#ifndef _SAVE_H_
#define _SAVE_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "osal_snv.h"
// #include "user_data.h"
#include "types.h"

#include "flashdb.h"
#include "fdb_def.h"
/*#############################################*/
extern struct fdb_tsdb xTsdb;
extern struct fdb_kvdb xKvdb;
extern struct fdb_kvdb xKvdbUserInfor;
/*#############################################*/
/* save struct. */
typedef struct
{
	uint8 leftMin;
	uint8 leftSecond;
	uint8 rightMin;
	uint8 rightSecond;
} userLastFeedData_t;

typedef struct
{
	// uint32_t timeStamp[4];
	uint16_t typeID;
	uint16_t Data;
} ActionLog_t;
//----------------------------------------------------------
#define UTC_TIME_KEY 			"KM_UTC"
#define REMOTE_MAC_KEY 			"KM_REMOTEMAC"
#define PILLOW_LAST_KEY 		"KM_PILLOWLAST"
#define LASTFEED_KEY_USE_DATA 	"LAST_FEED_KEY"
//----------------------------------------------------------
/* Flash DB initialization. */
void FlashDdInit(void);
fdb_time_t uxTimeStampGet(void);

void SaveInit(void);
void SaveDataFlush(void);

/* Delete all data. */
void StashDelete(void);

void tsdb_sample(fdb_tsdb_t tsdb);

void tsdb_test_set(fdb_tsdb_t tsdb, uint32_t timestamp);
void tsdb_test_QUERY(fdb_tsdb_t tsdb);
void kvdb_basic_sample(fdb_kvdb_t kvdb);
bool Usertsdb_readHistory(bool fcontinue, fdb_tsdb_t db, fdb_time_t from, fdb_time_t to);
void tsdb_appendPillowAction(ActionLog_t ActionLog);

#ifdef __cplusplus
}
#endif

#endif /* endif */
